﻿namespace ysh.ui
{
	using System;
	using Autodesk.Revit.UI;
	using core;
	using res;

	/// <summary>
	/// 
	/// </summary>
	public static class RevitPushButton
	{
		#region public methods

		public static PushButton Create(RevitPushButtonDataModel data)
		{
			//The button name based on unique identifier.
			var btnDataName = Guid.NewGuid().ToString();

			//Set the button data.
			var btnData = new PushButtonData(btnDataName, data.Label, CoreAssembly.GetAssemblyLocation(), data.CommandNameSpacePath)
			{
				ToolTip = data.Tooltip,
				LargeImage = RescourceImage.GetIcon(data.IconImageName),
				ToolTipImage = RescourceImage.GetIcon(data.TooltipImageName)
			};

			//Return created button and host it on panel provided in required data model.
			return data.Panel.AddItem(btnData) as PushButton;
		}
		#endregion
	}
}
